package com.gedi.springboot_kafka.kafka;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @Author:RenPu
 * @Date: 2020/3/19 22:01
 * @Version: 1.0
 * @description:
 */

@Component
public class ConsumerDemo {


    /**
     *
     * 接受方法，消费消息方法
     */

    //kafka监听器注解，订阅指定的主题
    @KafkaListener(topics = "t4")

    public void receive(ConsumerRecord<Integer,String> record){
        System.out.println(record.key()+"|"+record.value()+"|"+record.offset());

    }

}
